<!-- 头部开始 -->
<%- include templates/_meta_top.ejs %>
<!-- 头部结束 -->
    <!-- Web Goobal Style-->
    <link href="/css/backend/css/goobal.css" rel="stylesheet">
    <!-- Page Index Style-->
    <link href="/css/backend/css/index.css" rel="stylesheet">
  </head>

  <body class="nav-md">
    <div class="alert alert-success" role="alert">
        <strong><%- messages() %></strong>
    </div>
    <div class="container body">
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">
            <div class="navbar nav_title" style="border: 0;">
              <a href="index.html" class="site_title"><i class="fa  fa-globe"></i> <span style="margin-left:10px;">海&nbsp;量&nbsp;通</span></a>
            </div>
            <div class="clearfix"></div>
            <br/>
            <!-- 侧栏开始 -->
            <%- include templates/_sidebar.ejs %>
            <!-- 侧栏结束 -->
          </div>
        </div>
        <!-- 头部导航开始 -->
        <%- include templates/_topNav.ejs %>
        <!-- 头部导航结束 -->

        <!-- 内容开始 -->
        <div class="right_col" role="main">
            <!-- top title -->
            <div class="x_title">
              <h2>文章列表</h2>
              <a type="button" class="btn btn-primary navbar-right statForm" title="" href="/article/add">添加文章</a>
              <div class="clearfix"></div>
            </div>
            <div class="clearfix"></div>

            <!-- tongji -->
            <div class="row">
              <div class="col-md-12">
                  <div class="x_content">
                    <div class="row">
                      <!-- 文章表开始 -->
                        <table class="table planning-table">
                          <thead>
                            <tr>
                              <th>#</th>
                              <th>文章标题</th>
                              <th>文章内容</th>
                              <th>所属分类</th>
                              <th>评论数</th>
                              <th>点赞数</th>
                              <th>操作</th>
                            </tr>
                          </thead>
                          <tbody>
                            <% posts.forEach(function (post, index){ %>
                            <tr>
                              <th scope="row"><%= (index+1) %></th>
                              <td><a href="javaScript:;" class="advert-devisal-href"><%= post.title %></a></td>
                              <td><%= post.body %></td>
                              <td><%= post.category.name %></td>
                              <td><%= post.comments.length %></td>
                              <td><%= post.meta.favourates %></td>
                              <td class="advert-action">
                                <a href="/article/edit/<%=post._id%>">编辑</a>
                                <a href="/article/del/<%=post._id%>">删除</a>
                              </td>
                            </tr>
                            <% }) %>
                          </tbody>
                        </table>
                      <!-- 文章表结束 -->
                    </div>
                    <div class="row">
                        <div class="dataTables_info pull-left" id="datatable_info" role="status" aria-live="polite">
                          共<span><%= pageCount %></span>页，当前第<span><%=pageNumber%></span>页, 每页<span><%= posts.length %></span>条数据
                        </div>
                        <nav class="pull-right">
                          <ul class="pagination">
                            <li class="prev-page" data-id="<%= pageNumber %>"><a href="#">&laquo;</a></li>
                            <% for (var i = 0; i < pageCount; i++) {%>
                              <% if (pageNumber == (i+1)) {%>
                                <li class="active page-btn" id="page<%= (i+1)%>"><a href="/article?page=<%= (i+1)%>"><%= (i+1) %></a></li>
                              <% } else {%>
                                <li class="page-btn" id="page<%= (i+1)%>"><a href="/article?page=<%= (i+1)%>"><%= (i+1) %></a></li>
                              <%}%>
                            <% }%>
                            <li class="next-page" data-id="<%= pageNumber %>" data-count="<%= pageCount %>"><a href="#">&raquo;</a></li>
                          </ul>
                        </nav>
                    </div>
                </div>
            </div>
          </div>
        </div>
        <!-- 内容结束 -->

    <!-- 底部开始 -->
    <%- include templates/_meta_bottom.ejs %>
    <!-- 底部结束 -->
    <script type="text/javascript" src="/vendors/cookie/jquery.cookie.js"></script>
    <script type="text/javascript" src="/js/backend/main.js"></script>
    <script>
      function logout(){

        bootbox.dialog({
          title : "提示信息",
          message : "<p>退出系统 ？</p>",
          buttons : {
              "success" : {
                  "label" : "<i class='icon-ok'></i> 确认",
                  "className" : "btn-sm btn-success",
              },
              "cancel" : {
                  "label" : "<i class='icon-info'></i> 取消",
                  "className" : "btn-sm btn-danger",
                  "callback" : function() { }
              }
          }
        })
      }
    </script>
  </body>
</html>
